package ualrcdg.shared;

import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

/**
 * Utility class which dictates how parsing warnings/errors/fatal errors are handled by the utilized DOM parsers.
 */
class CDGParserErrorHandler implements ErrorHandler
{
	private static final CDGParserErrorHandler instance = new CDGParserErrorHandler( );
	
	/**
	 * 	Private nullary constructor
	 */
	private CDGParserErrorHandler( )
	{
	}
	
	/**
	 * @return the singleton instance of this class
	 */
	static CDGParserErrorHandler getInstance( )
	{
		return instance;
	}
	
	/*
	 * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
	 */
	@Override
	public void warning( SAXParseException e ) throws SAXException
	{
		//Ignore the parsing warning
		e.printStackTrace( );
	}

	/*
	 * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
	 */
	@Override
	public void fatalError( SAXParseException e ) throws SAXException
	{
		throw e;
	}

	/*
	 * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
	 */
	@Override
	public void error( SAXParseException e ) throws SAXException
	{
		throw e;
	}
};